#pragma once
#include <game/Config.h>

ARELLO_GAME_NAMESPACE_DECL_START

class ServiceBase
{
public:
	virtual ~ServiceBase()
	{ }
protected:
	static int NextMagic()
	{
		static int magic(0);
		return magic++;
	}
};

template<typename Derived>
class Service
	: public ServiceBase
{
public:
	Service()
	{
		static_cast<Derived*>(this); // Just a static assert to be sure that
									 // we are used in a proper way.
	}

	static int Magic()
	{
		static int result(NextMagic());
		return result;
	}
};

ARELLO_GAME_NAMESPACE_DECL_END